import { defineStore } from 'pinia'
import * as couponApi from "@/api/coupon"

export const useCouponStore = defineStore('coupon', () => {
	async function getActivatedCoupon(param ?: any) {
		const response = await couponApi.getActivatedCoupon(param)
		if (response.code === 200) {
			return response.data.coupon
		}
		return {}
	}

	async function doAcceptGoupon(param ?: any) {
		const response = await couponApi.doAcceptGoupon(param)
		if (response.code === 200) {
			return response.data.result
		} 
		return false
	}

	return {
		getActivatedCoupon,
		doAcceptGoupon
	}
})